//引入express
const express = require('express');
//导入路由
const router = require('./router/pro.js')
//导入body-parser
const bodyParser = require('body-parser');
//创建web服务器
const app = express();
//设置端口8080
app.listen(8080);
//指定静态托管
//设置跨域允许
const cors = require("cors");
app.use(cors({
    origin:["http://127.0.0.1:8080","http://localhost:8080"]
}))

app.use( express.static('public') );
//使用body-parser中间件 解析post传递的参数
app.use(bodyParser.urlencoded({
    extended:false
}));

const session = require("express-session");
app.use(session({
    name: 'session-id',
    secret: '12345-67890',
    saveUninitialized: true,
    resave: false
}))

//挂载路由
app.use('/pro',router);
